

import { reqTradeInfo } from '../api'

const trade = {
    namespaced: true,
    state: {
        // 订单交易信息
        tradeInfo: {}
    },
    mutations: {
        RECEIVE_TRADEINFO(state,tradeInfo){
            state.tradeInfo = tradeInfo
        }
    },
    actions: {
        async getTradeInfo({commit}){
            const result = await reqTradeInfo()
            if(result.code === 200){
                commit('RECEIVE_TRADEINFO',result.data)
                return 'ok'
            }else{
                return Promise.reject(new Error('getTradeInfo failed'))
            }
        }
    },
    getters:{
        detailArrayList(state){
            return state.tradeInfo.detailArrayList || []
        }
    },
}

export default trade